package secondStage.part5.网络编程.TCP通信程序;

import java.io.*;
import java.net.Socket;

/**
 * @ClassName: [ClientTcpSendTest]
 * @Description: TCP通信程序，发送信息,数据来自于文本文件
 * @Author: [黄劲松]
 * @CreateDate: [2021-04-06]
 * @Version: [v1.0]
 */
//客户端:数据来自于文本文件
public class ClientTcpSendTest3 {
    public static void main(String[] args) throws IOException {
        //创建客户端的Socket对象(Socket)
        Socket s = new Socket("192.168.1.115", 8080);
        //数据来自于文本文件
        BufferedReader br = new BufferedReader(new FileReader("javaSE.txt"));
        //封装输出流对象写数据
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
        String line;
        while ((line=br.readLine())!= null){
            bw.write(line);
            bw.newLine();
            bw.flush();
        }
        bw.close();
        s.close();
    }
}
